// INSE6260-ATM Simulator Project

/**
 * View package contains ATMS GUI.
 */
package com.inse6260.atms.view;

import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JLabel;

/**
 *
 * @author dimitri.tiago
 */
public class LogInPanel extends javax.swing.JPanel
{
    /** Creates new form LogInPanel */
    public LogInPanel()
    {
        initComponents();

        // hide password field input until card validated.
        passwordLabel.setVisible(false);
        passwordInputTextField.setVisible(false);
    }

    /**
     * Returns card input textfield.
     * @return card input textfield.
     */
    public JTextField getCardTextField()
    {
        return cardInputTextField;
    }

    /**
     * Returns password input field
     * @return password input field
     */
    public JPasswordField getPasswordTextField()
    {
        return passwordInputTextField;
    }

    /**
     * Shows the password field for input
     * @param show boolean variable indicating if to show or not the password field.
     */
    public void showPasswordField(boolean show)
    {
        passwordLabel.setVisible(true);
        passwordInputTextField.setVisible(true);
        this.validate();
    }

    /**
     * Returns failure reason label
     * @return failure reason label
     */
    public JLabel getFailureReasonLabel()
    {
        return failureReasonLabel;
    }

    public void clearInputFields()
    {
        cardInputTextField.setText("");

        passwordInputTextField.setText("");
        passwordInputTextField.setVisible(false);
        passwordLabel.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        welcomeLabel = new javax.swing.JLabel();
        cardInputTextField = new javax.swing.JTextField();
        passwordInputTextField = new javax.swing.JPasswordField();
        cardLabel = new javax.swing.JLabel();
        passwordLabel = new javax.swing.JLabel();
        failureReasonLabel = new javax.swing.JLabel();

        setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        welcomeLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
        welcomeLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        welcomeLabel.setText("Welcome to Your Bank");

        cardInputTextField.setBackground(new java.awt.Color(255, 255, 255));
        cardInputTextField.setColumns(6);
        cardInputTextField.setEditable(false);
        cardInputTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        cardInputTextField.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        cardInputTextField.setEnabled(false);
        cardInputTextField.setName("cardInputField"); // NOI18N
        cardInputTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cardInputTextFieldActionPerformed(evt);
            }
        });

        passwordInputTextField.setBackground(new java.awt.Color(255, 255, 255));
        passwordInputTextField.setEditable(false);
        passwordInputTextField.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        passwordInputTextField.setEnabled(false);
        passwordInputTextField.setName("passwordField"); // NOI18N
        passwordInputTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                passwordInputTextFieldActionPerformed(evt);
            }
        });

        cardLabel.setText("Card number:");

        passwordLabel.setText("PIN:");

        failureReasonLabel.setFont(new java.awt.Font("Tahoma", 1, 12));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(114, 114, 114)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(failureReasonLabel, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                    .addComponent(welcomeLabel, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.CENTER, layout.createSequentialGroup()
                        .addComponent(passwordLabel)
                        .addGap(63, 63, 63)
                        .addComponent(passwordInputTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.CENTER, layout.createSequentialGroup()
                        .addComponent(cardLabel)
                        .addGap(18, 18, 18)
                        .addComponent(cardInputTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)))
                .addGap(138, 138, 138))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(62, 62, 62)
                .addComponent(welcomeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cardInputTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cardLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(passwordLabel)
                    .addComponent(passwordInputTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addComponent(failureReasonLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(57, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void cardInputTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cardInputTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cardInputTextFieldActionPerformed

    private void passwordInputTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_passwordInputTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_passwordInputTextFieldActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField cardInputTextField;
    private javax.swing.JLabel cardLabel;
    private javax.swing.JLabel failureReasonLabel;
    private javax.swing.JPasswordField passwordInputTextField;
    private javax.swing.JLabel passwordLabel;
    private javax.swing.JLabel welcomeLabel;
    // End of variables declaration//GEN-END:variables

}
